#!/bin/bash



function mvn_init() {

  local package pkg
  package="$1"
  pkg=$( echo "$package" | sed 's/\./\//g' )

  mkdir -p src/main/java/"${pkg}"
  touch src/main/java/"${pkg}"/.gitignore

  mkdir -p src/main/resources
  touch src/main/resources/.gitignore

  mkdir -p src/test/java/"${pkg}"
  touch src/test/java/"${pkg}"/.gitignore

  mkdir -p src/test/resources
  touch src/test/resources/.gitignore

}




current_dir=$( pwd )
users="core svc web"



for user in $users; do

  mkdir -p "${current_dir}/examination-system-${user}"
  cd "${current_dir}/examination-system-${user}" || exit 1

  mvn_init cc.eddic.examinationsystem

  cat > pom.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>cn.eddic</groupId>
        <artifactId>examination-system</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>

    <artifactId>examination-system-${user}</artifactId>
    <name>examination-system-${user}</name>
    <description>examination system ${user}</description>

    <dependencies>
        <dependency>
            <groupId>cn.eddic</groupId>
            <artifactId>examination-system-core</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>
EOF

done


